<!DOCTYPE html>
<html>
<head>
    <title>CSII luckysheet</title>
    <meta charset="utf-8">
    <link rel='stylesheet' href='luckysheet.css'/>
    <script type="text/javascript" src="jquery.min.js"></script>
    <script type="text/javascript" src="my.js"></script>
    <script type="text/javascript">
    $(function () {
        var user = $.loadUser("user");

        $.get("http://"+ location.host +"/list",
            function(data) {
                console.log("get list="+data);
                $("#fileList").find("tr").remove();
                for (var i=0;i<data.length;i++) {
                    $("#fileList").append("<tr><td><a href=\"sheet.html?file=" + encodeURIComponent(data[i]) + "\">" + data[i] + "</a></td></tr>");
                }
            },
            "json");

        $('#fileNew').click(function(){
            var file = $('#fileName').val();
            console.log("new file="+file);
            if (file != null && file.length > 0) {
                var sheetUri = "sheet.html?file=" + encodeURIComponent(file);
                console.log("sheetUri="+sheetUri);
                $(location).attr("href",sheetUri);
            }
        });
    })

    </script>
</head>
<body>
<table id="fileList">
</table>
<br/>
<input type="text" id="fileName" value=""/>
<input type="button" id="fileNew" value="新建文件"/>
</body>
</html>